﻿<HTML>
<HEAD>
<TITLE>ARRAY Title</TITLE>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<META HTTP-EQUIV="imagetoolbar" CONTENT="NO">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Expires" CONTENT="-1"> 

 
<link href="ModalDialogs.css" rel="stylesheet" type="text/css" />
    
<Script LANGUAGE="JavaScript" src="ajax_xmlhttp.js">
</Script>
<Script LANGUAGE="JavaScript" src="scw.js">
</Script>

<Script LANGUAGE="JavaScript">

//==============================================================================================================
//NEXT Part is AJAX Remote Scripting +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//==============================================================================================================

 function show_savepage(actionit, indxk, sortby, row_ID, page_ID, skipcount, pagesize)
 {                       
                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                   //Change ajax called program name (ie AJAX_UPD)
                   var requestURLIT = 'ajax_kgrid_add.php?action=' + actionit + '&r=' + new Date().getTime()
                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                   var url = requestURLIT + '&num=' + indxk + '&sortby=' + sortby + '&rowid=' + row_ID + '&pageid=' + page_ID + '&skip=' + skipcount
                   url = url + '&pagesize=' + pagesize
                   //pass total record count, so as to see whether to use skipcount
                   url = url + '&totcount=' +   parent.document.getElementById('TotalNoRecords').value

                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                   // May have to add other datagrid Search criteria
                   //Add Search criteria next here (NOTE:- If Not using datagrid frame in conjunction, then DO NOT Use)
                   url = url + '&arraysearch=' +   parent.document.getElementById('textsearch').value
                   //url = url + '&machsearch=' +   parent.document.getElementById('ddldropdown').value
                   //...................................................................................................................................................................................................

                   //Add Field Data to be saved here (put escape on all text fields)
                   url = url + '&machtosave=' + document.getElementById('ddldropdown').value
                   url = url + '&arraytosave=' + document.getElementById('textarray').value
                   url = url + '&startdatetosave=' + escape(document.getElementById('textsdate').value)
                   url = url + '&enddatetosave=' + escape(document.getElementById('textedate').value)
                   url = url + '&notetosave=' + document.getElementById('textnote').value
                   url = url + '&chktosave=' + document.getElementById('check1').checked
                  //url = url + '&notetosave=' + escape(document.getElementById('textnote').value)
                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



                   //alert("url is " + url);
	   xmlHttp = GetXmlHttpObject(stateChangeHandlerSAVE); 
	   xmlHttp_Get(xmlHttp, url); 
 }



//Next function is just for delaying the Error Message a bit
//------------------------------------------------------------------------
function ShowAlert(str1) 
{ 
 alert(str1); 
}

//=======================================================================================================================================================
// Next functions are run after the above functions, so as to see when the Remote page has been completed
// stateChangeHandler will fire when the state has changed, i.e. data is received back 
// This is non-blocking (asynchronous) 
//=======================================================================================================================================================
function stateChangeHandlerSAVE() 
{ 
                                          var rowID1;
		           //readyState of 4 or 'complete' represents that data has been returned 
		           if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
                                           { 
		             //Gather the results from the callback 
		             var str = xmlHttp.responseText; 
                                        
                                              //Next 2 lines stop Progress Bar in Grid frame
                                              parent.document.getElementById("pnlpopupprogress").style.display = "none";
                                              //parent.document.getElementById('overlayprogress').style.visibility="hidden";


                                             //If validation Error found, then display error concerned
                                             if (str.substring(0,5) == "Error")
                                             {
                                                setTimeout("ShowAlert(' " + str + " ')",10)     
                                                //alert(str);      
                                             }
                                             else
                                             {

                                               parent.document.getElementById("pnlpopupprogress").style.display = "none";
                                               parent.document.getElementById('overlayprogress').style.visibility="hidden";

                                               if (str == "")     //only saving field not part of datagrid
                                                {
                                                   //do nothing
                                                }  
                                               else
                                                {
                                                  //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                                                  //The next Part is you are using a datagrid LIST inconjunction (so can be taken out for standalone update form)
                                                  //------------------------------------------------------------------------------------------------------------------------

                                                  parent.document.getElementById('nameList2').innerHTML = str;

                                                  rowID1 = parent.document.getElementById('RowIDGet').value;
                                                 //alert("rowID1 is " + rowID1);

                                                 //Check if Search Criteria should be made blank, ie have changed a search criteria field(so do reload)
                                                 if (parent.document.getElementById('chkresetcriteria').value  == ' True ')
                                                 {
                                                    //parent.document.form1.ddldropdown.options[0].selected = true;    //Note: Must have values in dropdown to work
                                                    parent.document.getElementById('textsearch').value = "";
                                                 }

                                                 parent.resetablebg();
                                                //set column sort header to a different background color
                                                parent.setBgColor(parent.document.getElementById('SortFieldGet').value);
                                                var table = parent.document.getElementById('myTable');
                                                if (table)   
                                                {
                                                 //Highlight 1st Row of new Page
                                                 table.rows[rowID1].style.backgroundColor="#F3F3F3";
                                                 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                                                 //Highlight Input Textbox row as well (Comment out if no Input Textbox used in List)
                                                 //parent.document.getElementById('aa' + rowID1 + 'c7').style.backgroundColor="#F3F3F3";
                                                 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                                             
                                                 CloseUpd ();
                                                }   
                                                //------------------------------------------------------------------------------------------------------------------------
                                                //END of Part if using a datagrid LIST inconjunction (so can be taken out for standalone update form
                                               //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


                                               }  //if (str == "")

                                             }   // if (str.substring(0,5) == "Error")


		           }    // if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')

} 



//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Please change as required
//------------------------------------------------------------------------------------------------------------------------------------------
function setFocus()
{
    //document.getElementById('ddldropdown').focus();
    //alert("PKID is " &document.getElementById('textcurrentpkid'));

}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Please change as required
//---------------------------------------------------------------------------------------------------------------------------------------------
function SaveClick()
{
 //alert("Clicked on SAVE button2");
 var action = "reset";
 //var indxk = document.getElementById('PK_ID').value;  //PKID
 var indxk = "";

 var row_ID = 0;
 var skipcount = 0;
 var sortby = "";
 var pagesize = 0;
 var page_ID = 0;
 //Please change next 3 lines as required (ie Datagrid list Search and Sort fields)
 var machtosave = "";
 var arraytosave = "";
 var startdatetosave = "";

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//The following lines are when there is a LIST used in conjunction, take out for standalone
 row_ID = parent.document.getElementById('RowIDGet').value;
 skipcount = parent.document.getElementById('SkipCount').value;
 sortby = parent.document.getElementById('SortFieldGet').value;
 pagesize = parent.document.getElementById('PageSizeGet').value;
 page_ID = parent.document.getElementById('CurrentPageGet').value;  
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//NOTE:- Take out for standalone
   parent.document.getElementById("pnlpopupprogress").style.display = "block";
   parent.document.getElementById('overlayprogress').style.visibility="visible";
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Please amend second line of next, for Search and Sort fields. NOTE:- Can leave as is for standalone
//--------------------------------------------------------------------------------------------------------------------------------------
 show_savepage(action, indxk, sortby, row_ID, page_ID, skipcount, pagesize);
                     
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

}



function CloseUpd () 
{
   parent.CloseUpd();
}


function CloseCal()
{
 document.getElementById("iframediv").style.display = "none";
 document.getElementById('overlayprogress').style.visibility="hidden";  //hides gray background
 overlay();  //hide iframe (popup)
}

function calstartpopup()
{
  
   //alert("in Calendar ");
   //New KLE Code for IFRAME POPUP alternative
   var ifram = document.getElementById('iframeupd');
   ifram.src = "kgrid_calendar.aspx?textbox=textsdate&textlabel=Start Date" 
       //            "&num=" + document.getElementById('textcurrentpkid').value;
                          
   document.getElementById("iframediv").style.display = "block";
   document.getElementById('overlayprogress').style.visibility="visible";   //shows gray background
   overlay();  //show iframe (popup)
                           
}


//Open or Closes iframe modal fake popup
function overlay() 
{
    //alert("open overlay");
	el = document.getElementById("overlay2");
	//el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
    el.style.display = (el.style.display == "block") ? "none" : "block";
}


function testscw()
{
 //alert("after close scw");
}



</Script>


</head>


<!--&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->
<body bgColor="white" onload="setFocus()">
<!--&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->


<form name="form1" method="post" id="form1">

<div id=overlay style="POSITION: absolute; 
             LEFT: 1px;  
             VISIBILITY: hidden;
             TOP: 1px; 
             HEIGHT: 900px;
             WIDTH: 900px;
             Z-INDEX: 300"> 
      <img src="images/PNG_1000x1000.png" alt="" />
</div>


<div style="position: absolute; left: 1px; top: 1px; z-index: 100;">     
          <input id="Button344" type="button"  onclick="SaveClick()" style="text-align:center"
           value="Save" />
</div>

 <div style="position: absolute; left: 47px; top: 1px; z-index: 100;">     
          <input id="Button345" type="button"  onclick="CloseUpd()" style="text-align:center"
           value="Cancel" />
</div> 



<!--Close Button using only Javascript-->
 <span style="position: absolute; visibility: visible; left: 580px; top: 1px; z-index: 100">
         <a href="javascript:CloseUpd()">
                <img src="images/Close-image2.jpg" alt="Close" width="19" height="21" border="0">
         </a>
 </span>



<span style="POSITION: absolute; 
             LEFT: 240px;  
             TOP: 4px; 
             HEIGHT: 30px;
             WIDTH: 200px;
             BACKGROUND-COLOR: white;
             COLOR: #396DA3;
             FONT-WEIGHT: bold;
             FONT-SIZE: 14px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 2">  
 Array Details
</span>



<!--Start of Machine field-->            
<span id="Machine" style="display:inline-block;height:21px;width:100px;FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 118px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 48px; 
                    BACKGROUND-COLOR: white">
               Machine:
</span>
    



<span id="lblarray" style="display:inline-block;height:21px;width:100px;FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 357px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 48px; 
                    BACKGROUND-COLOR: white">
               Array:
</span>  

<input id="textarray" tabIndex="2"
      style="POSITION: absolute; 
             LEFT: 393px;  
             TOP: 46px; 
             HEIGHT: 20px;
             WIDTH: 145px;
             BACKGROUND-COLOR: white;
             COLOR: black;
             FONT-WEIGHT: bold;
             FONT-SIZE: 12px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 100">
</input>



<span style="POSITION: absolute; 
               LEFT: 79px; 
               TOP: 74px;  
               Z-INDEX: 100">
   <a href='#' onclick='scwShow(textsdate,textsdate);return false;'>
      <img SRC="images/calendar1.bmp" ALT="Select Date" 
     WIDTH="28" HEIGHT="28" border="0">
   </a>
</span>
<span id="StartDate" style="display:inline-block;height:21px;width:100px;FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 109px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 78px; 
                    BACKGROUND-COLOR: white">
               Start Date: 
</span>     
<input id="textsdate" 
      style="POSITION: absolute; 
             LEFT: 171px;  
             TOP: 76px; 
             HEIGHT: 19px;
             WIDTH: 70px;
             BACKGROUND-COLOR: white;
             COLOR: black;
             FONT-WEIGHT: normal;
             FONT-SIZE: 11px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 100"       
      tabIndex="3">
</input>




<span style="POSITION: absolute; 
               LEFT: 305px; 
               TOP: 74px;  
               Z-INDEX: 100">
   <a href='#' onclick='scwShow(textedate,textedate);return false;'>
      <img SRC="images/calendar1.bmp" ALT="Select Date" 
     WIDTH="28" HEIGHT="28" border="0">
   </a>
</span>
<span id="EndDate" style="display:inline-block;height:21px;width:100px;FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 338px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 78px; 
                    BACKGROUND-COLOR: white">
               End Date:
</span>     
<input id="textedate" 
      style="POSITION: absolute; 
             LEFT: 393px;  
             TOP: 76px; 
             HEIGHT: 19px;
             WIDTH: 70px;
             BACKGROUND-COLOR: white;
             COLOR: black;
             FONT-WEIGHT: normal;
             FONT-SIZE: 11px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 100"       
      tabIndex="4">
</input>


<span id="lblnotes" style="display:inline-block;height:21px;width:75px;FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 130px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 117px; 
                    BACKGROUND-COLOR: white">
               Notes:
</span>  
<textarea id="textnote" rows="2" cols="20" id="textnote" tabIndex="5"
     style="HEIGHT: 45px; 
            LEFT: 171px; 
            FONT-SIZE: 12px; 
            COLOR: Blue; 
            FONT-FAMILY: arial;
            POSITION: absolute; 
            TOP: 117px; 
            WIDTH: 270px; 
            Z-INDEX: 100">
</textarea>
           

<span style="HEIGHT: 50px;
             LEFT: 71px;
             FONT-SIZE: 12px;
             COLOR: Blue;
             FONT-FAMILY: arial;
             POSITION: absolute;
             TOP: 170px;
             WIDTH: 270px;
             Z-INDEX: 100">
      <label for='check1'>Completed?</label>
      <input id='check1' type='checkbox' name='check1' onclick='javascript: SaveClick();' tabindex='6' />
</span>



<CheckBox id="check1" 
     style="HEIGHT: 50px; 
            LEFT: 71px; 
            FONT-SIZE: 12px; 
            COLOR: Blue; 
            FONT-FAMILY: arial;
            POSITION: absolute; 
            TOP: 170px; 
            WIDTH: 270px; 
            Z-INDEX: 100" 

     Text="Completed?" TextAlign="Left"
     tabIndex="6"
     runat="server">
</CheckBox>




    <div id="overlayprogress" class="modalBackground22" style="position: absolute; left: 1px;
        visibility: hidden; top: 1px; height: 318px; width: 598px; z-index: 300">
    </div>
    <div id="overlay2">
        <div>
            <div id="iframediv" style="position: absolute; left: 45px; top: 38px; display: none;
                background-color: white; z-index: 400">
                <iframe id="iframeupd" width='280' height='220' frameborder='0' scrolling='no' src=''>
                </iframe>
            </div>
        </div>
    </div>
    



    <?php

      $strAction = $_REQUEST["action"];  
      $strPKID = $_REQUEST["num"];  
      $strSQL = "";
         
      $dsn2="SQLSERVER2005";
      $username2="sa";
      $password2="and";
  
      $sqlconnect2=odbc_connect($dsn2,$username2,$password2);

      $cRet = "";

      $cRet = $cRet . "<select name='ddldropdown' id='ddldropdown' tabindex='1' OnChange='javascript: SaveClick();' ";
      $cRet = $cRet . "   style='POSITION: absolute; ";
      $cRet = $cRet . "       LEFT: 171px; "; 
      $cRet = $cRet . "       TOP: 46px; ";
      $cRet = $cRet . "       HEIGHT: 19px; ";
      $cRet = $cRet . "       WIDTH: 110px; ";
      $cRet = $cRet . "       BACKGROUND-COLOR: white; ";
      $cRet = $cRet . "       COLOR: brown; ";
      $cRet = $cRet . "       FONT-WEIGHT: bold; ";
      $cRet = $cRet . "       FONT-SIZE: 12px; ";
      $cRet = $cRet . "       FONT-FAMILY: arial; ";
      $cRet = $cRet . "       FONT-STYLE: normal; ";
      $cRet = $cRet . "       Z-INDEX: 100' > ";

    
      $strSQL2 = "SELECT description FROM Machine order by description";

      $rs2=odbc_exec($sqlconnect2, $strSQL2);

      while (odbc_fetch_row($rs2))
      {

            if (odbc_result($rs2,"description") == ""
                   || (strlen(odbc_result($rs2,"description")) == 0))      
            {
                $strDescription = "";
            }
            else
            {
                $strDescription = odbc_result($rs2,"description");
            }


            $cRet = $cRet . "<option value='" . $strDescription . "'>" . $strDescription . "</option>";
           


      }   //end of While


      $cRet = $cRet . "</select>";


      odbc_close($sqlconnect2);



      echo $cRet;

      //phpinfo();

    ?>



</form>


</BODY>

</HTML>



